package com.hdwmw.util;

import com.hdwmw.R;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MyView extends LinearLayout {
	private ImageView iv;
	private TextView tv;
	public MyView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public MyView(Context context,String text,boolean on) {
		super(context);
		if(!on) {
			setVisibility(View.GONE);
		} else {
			iv = new ImageView(context);
			tv = new TextView(context);
			iv.setImageResource(R.drawable.duihao);
			LayoutParams lp_iv = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
			lp_iv.gravity = Gravity.CENTER_VERTICAL;
			iv.setLayoutParams(lp_iv);
			
			tv.setTextSize(DimensUtil.dipTopx(context, 10));
			tv.setText(text);
			LayoutParams lp_tv = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
			lp_tv.gravity = Gravity.CENTER_VERTICAL;
			tv.setLayoutParams(lp_tv);
			
			addView(iv);
			addView(tv);
			setPadding(0, 0, 20, 0);
		}
	}

	
}
